package com.ruoyi.ship.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ship.domain.TqwlShipInfo;
import com.ruoyi.ship.service.ITqwlShipInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 船信息Controller
 * 
 * @author ruoyi
 * @date 2021-11-05
 */
@RestController
@RequestMapping("/ship/info")
public class TqwlShipInfoController extends BaseController
{
    @Autowired
    private ITqwlShipInfoService tqwlShipInfoService;

    /**
     * 查询船信息列表
     */
    @PreAuthorize("@ss.hasPermi('ship:info:list')")
    @GetMapping("/list")
    public TableDataInfo list(TqwlShipInfo tqwlShipInfo)
    {
        startPage();
        List<TqwlShipInfo> list = tqwlShipInfoService.selectTqwlShipInfoList(tqwlShipInfo);
        return getDataTable(list);
    }

    /**
     * 导出船信息列表
     */
    @PreAuthorize("@ss.hasPermi('ship:info:export')")
    @Log(title = "船信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TqwlShipInfo tqwlShipInfo)
    {
        List<TqwlShipInfo> list = tqwlShipInfoService.selectTqwlShipInfoList(tqwlShipInfo);
        ExcelUtil<TqwlShipInfo> util = new ExcelUtil<TqwlShipInfo>(TqwlShipInfo.class);
        return util.exportExcel(list, "船信息数据");
    }

    /**
     * 获取船信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ship:info:query')")
    @GetMapping(value = "/{shipId}")
    public AjaxResult getInfo(@PathVariable("shipId") Long shipId)
    {
        return AjaxResult.success(tqwlShipInfoService.selectTqwlShipInfoByShipId(shipId));
    }

    /**
     * 新增船信息
     */
    @PreAuthorize("@ss.hasPermi('ship:info:add')")
    @Log(title = "船信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TqwlShipInfo tqwlShipInfo)
    {
        return toAjax(tqwlShipInfoService.insertTqwlShipInfo(tqwlShipInfo));
    }

    /**
     * 修改船信息
     */
    @PreAuthorize("@ss.hasPermi('ship:info:edit')")
    @Log(title = "船信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TqwlShipInfo tqwlShipInfo)
    {
        return toAjax(tqwlShipInfoService.updateTqwlShipInfo(tqwlShipInfo));
    }

    /**
     * 删除船信息
     */
    @PreAuthorize("@ss.hasPermi('ship:info:remove')")
    @Log(title = "船信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shipIds}")
    public AjaxResult remove(@PathVariable Long[] shipIds)
    {
        return toAjax(tqwlShipInfoService.deleteTqwlShipInfoByShipIds(shipIds));
    }
}
